from datetime import datetime

# 教材模型类
class TextbooksModel:
    def __init__(self, id=None, name=None, publisher=None, grade=None, semester=None, 
                 academic_system=None, curriculum_standard=None, image_url=None, created_at=None):
        self.id = id
        self.name = name
        self.publisher = publisher
        self.grade = grade
        self.semester = semester
        self.academic_system = academic_system
        self.curriculum_standard = curriculum_standard
        self.image_url = image_url
        self.created_at = created_at
    
    def to_dict(self):
        return {
            'id': self.id,
            'name': self.name,
            'publisher': self.publisher,
            'grade': self.grade,
            'semester': self.semester,
            'academic_system': self.academic_system,
            'curriculum_standard': self.curriculum_standard,
            'image_url': self.image_url,
            'created_at': self.created_at.isoformat() if isinstance(self.created_at, datetime) else self.created_at
        }